/*
	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Library General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
*/

#ifndef __TEMPLATESMODEL_H__
#define __TEMPLATESMODEL_H__

#include <QObject>
#include <QListWidget>
#include <QAction>

class TemplateItem : private QObject
{
	Q_OBJECT
public:
	TemplateItem(QString name, QString creationDate, QString data, bool selected);

	QString templateName;
	QString templateCreationDate;
	QString templateData;
	bool templateSelected;
};

class TemplateManager : public QObject
{
	Q_OBJECT
public:
	TemplateManager();
	~TemplateManager();
	
	int getTemplateCount();
	QString getTemplateName(int index);
	QString getTemplateData(int index);
	bool isTemplateSelected(int index);
	
	QString getTemplateDataByName(QString name);
	
	void setTemplateName(int index, QString newName);
	void setTemplateSelected(int index, bool value);
	
	bool doTemplateExist(QString name);
	void updateModelFromList(QListWidget *list);
	
	void addTemplate(QString name, QString data);

private:
	QList<TemplateItem *> *templateList;
	
	QList<QAction *> actionList;
	
	void readTemplates();
	void writeTemplates();
};

#endif // __TEMPLATESMODEL_H__
